<template>
	<layout :loading="loading" curPage="role" :title="data.id ? '修改角色':'新增角色'">

		<form class="layui-form" @submit="submit" data-action="/admin/role/save" data-rediret="/pages/role/roleList">

			<div class="layui-col-md6">
				
				<inputGroup name="x.name|角色名称" title="角色名称" :value="data.name"></inputGroup>
				
				<radioGroup title="类型" name="x.type" :list="typeList" :value="data.type"></radioGroup>
				
				<textareaGroup title="角色描述" name="x.remark|角色描述|empty" :value="data.remark?data.remark:''" :maxlength="200" placeholder="选填"></textareaGroup>

			</div>
			
			<div class="layui-col-md12">
				
				<div class="layui-form-item">
					<label class="layui-form-label">权限配置</label>
					<div class="layui-input-block" style="margin-left: 140px;">
						<menuGroup :list="menuList" name="x.menuIds" :value="data.menuIds"></menuGroup>
					</div>
				</div>
			
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="hidden" name="x.id" :value="id" style="display: none;">
					<button class="layui-btn" form-type="submit">{{ !data.id ? '保存' : '修改'}}</button>
					<button class="layui-btn layui-btn-primary" form-type="reset">重置</button>
					<button class="layui-btn layui-btn-primary" @click="kit.goBack('index')">取消</button>
				</div>
			</div>
		</form>

	</layout>
</template>

<script>
	export default {
		data() {
			return {
				loading: false,
				id : '' ,
				data : {
					
				},
				typeList:[],
				menuList:[],
			}
		},
		onLoad(params) {
			this.id = params.id ;
		},
		onShow() {
			this.loadData();
		},
		methods: {
			
			submit:function(e){
				this.form.submit(e);
			},
			
			loadData : function(e){
				var that = this ;
				var data = {
					id : this.id 
				} ;
				this.kit.get("/admin/role/info",data,function(res){
					that.data = res.data || {};	
					that.menuList = res.menuList ;	
					that.typeList = res.typeList ;	
				});
			}
		}
	}
</script>

<style>

</style>
